import request from '@/utils/request'
import data from '@/views/pdf/content'
import Cookies from 'js-cookie';
export function login(data) {
  return request({
    url: '/firstaid-platform/userCenter/login/loginIn',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  // return Promise.resolve({
  //   code : 200,
  //   success: true ,
  //   msg:"ok",
  //   data : {
  //     roles:['admin'],
  //     name :"mark",
  //     avatar: "",
  //     introduction : ""
  //   }
  // })
  const data = JSON.parse(Cookies.get("loginJson"));
  return Promise.resolve({
    success: true ,
    data : {
      ...data,
      roles : [data.accountType]
    }
  })
  return request({
    url: '/firstaid-platform/userCenter/login/selectUserInfoByRedisKey',
    method: 'get',
    params: { key:token }
  })
}

export function logout() {
  const loginJson = Cookies.get("loginJson");
  const userInfo = JSON.parse(loginJson);
  /**
   *  userInfo 对象
accountName
accountType
cropID
deptId
deptName
loginName
permissionVos[]
roles[]
time
token
userId
userName
   */
  const {userId, accountType, } = userInfo ;
  return request({
    url: '/firstaid-platform/userCenter/login/loginOut',
    method: 'post',
    data: {userId: userId}
  })
}
